import Vue from 'vue'
export default {
  state: {
    currentTemplateId: null,
    nextTicketAppList: [],
    nextTicketAppListfoForNt: []
  },
  mutations: {
    SET_NEXT_TICKET_APP_LSIT: (state, list) => {
      state.nextTicketAppList = list
    },
    SET_NEXT_TICKET_APP_LSIT_FOR_NT: (state, list) => {
      state.nextTicketAppListForNt = list
    }
  },
  actions: {
    getNextTicketAppList ({
      commit
    }) {
      return new Promise((resolve, reject) => {
        Vue.prototype.$interface.reports.getNextTicketAppList().then(({
          data: response
        }) => {
          if (response.code !== 0) {
            throw response.msg
          }
          const list = response.data || {}
          commit('SET_NEXT_TICKET_APP_LSIT', list)

          resolve(list)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getNextTicketAppListForNt ({
      commit
    }) {
      return new Promise((resolve, reject) => {
        Vue.prototype.$interface.pay.getUserNextTicketApp().then(({
          data: response
        }) => {
          if (response.code !== 0) {
            throw response.msg
          }
          const list = response.data || {}
          commit('SET_NEXT_TICKET_APP_LSIT_FOR_NT', list)

          resolve(list)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
